from model import StudentInfo
import utils

# 使用列表存储学生对象
StudentInfoObject = []
r_object = utils.get_read_file_object()
# 先把StudentInfo.csv文件标头读取去掉
r_object.readline()
while True:
    #
    data = r_object.readline().strip()
    if data:
        StudentInfoObject.append(StudentInfo(data))
    else:
        r_object.close()
        break

while True:
    try:
        utils.print_mean()
        num = input("请输入操作序号:")
        if num == "1":
            sid = input("请输入查询的学号:")
            utils.select_one_student_info(StudentInfoObject, sid)
            continue
        elif num == "2":
            utils.select_all_student_info(StudentInfoObject)
            continue
        elif num == "3":
            str_data = input("请输入要添加的学生数据并用','间隔:")
            utils.add_student_info(StudentInfoObject, str_data)
            continue
        elif num == "4":
            str_data = input("请输入要删除的学生学号:")
            utils.delete_student_info(StudentInfoObject, str_data)
            continue
        elif num == "5":
            str_data = input("请输入要修改的学生数据并用','间隔:")
            utils.alter_student_info(StudentInfoObject, str_data)
            continue
        elif num == "6":
            utils.exit_system(StudentInfoObject)
        else:
            print("请正确输入序号!")
            continue
    except Exception:
        print("请正确输入信息!")
        continue